use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct yata::indicators::FisherTransform

///
///  参见[FTF](https://www.investopedia.com/terms/f/fisher-transform.asp)
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct FTF {
    ///2 signals
    ///Signal 1 appears when main value crosses zero line.
    /// When main value changes direction, returns signal corresponds to relative position of main value in zone
    pub signal0: Option<IndicatorActionWrap>,
    ///Signal 2 appears when main value crosses signal line and after signal 1 appears
    pub signal1: Option<IndicatorActionWrap>,

    /// 2 values
    /// FT main value
    /// Range in (-inf; +inf).
    pub main: ValueType,

    ///
    /// signal value line
    /// Range in (-inf; +inf).
    pub signal: ValueType,
}

/// Configuration
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct FTFConfig {
    /// period1: PeriodType
    /// Main period for max/min values calculation. Default is 9.
    ///
    /// Range in [2; PeriodType::MAX).
    pub period1: PeriodType,
    ///zone: ValueType
    ///Zone size for signals. Default is 1.5.
    ///
    ///Range in (0.0; +inf)
    pub zone: ValueType,
    /// signal: M
    /// Signal line moving average type.
    ///
    /// Default is SMA(2).
    ///
    /// Period range in [2; PeriodType::MAX).
    pub signal: PeriodType,
    //source: Source
    //Source type of values. Default is TP
}

impl Default for FTFConfig {
    fn default() -> Self {
        Self {
            period1: 9,
            zone: 1.5,
            signal: 2,
            //source: Source::TP,
        }
    }
}
